<template>
  <div class="viewPdf">
    <el-dialog
      :visible.sync="pdfDialogVisible"
      :title="fileName"
      :close-on-click-modal="false"
      class="supplier-edit-dialog bg-gray"
      width="900px" top="5px"
      @close="pdfClose">
      <!--<div style="height:70vh;overflow:auto">
      </div>-->
      <iframe id="pdfIframe"
              style="height:660px;width:860px;text-align:center;margin:-20px 0 20px 0;" frameborder="0" scrolling="auto"
              :src="pdfUrl"></iframe>
    </el-dialog>
  </div>
</template>
<script>

export default {
  name: 'viewPdf',
  metaInfo: {
    meta: [
      {httpEquiv:'Content-Security-Policy', content:'upgrade-insecure-requests'}
    ]
  },
  props: {
    pdfUrl: {
      type: String,
      default: ''
    },
    isPrint: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      fileName: '查看PDF文件',
      pdfDialogVisible: false,
      disabled: false
    }
  },
  methods: {
    pdfClose() {
      this.$parent.handleClickForPrint()
      // 执行父组件中的 hand****方法
    },
    handleCreate() {
      this.pdfDialogVisible = true
    }
  },
  watch: {
    pdfUrl(val){
      if(val){
        let arr = val.split('/')
        this.fileName = arr[(arr.length - 1)]
      }
    }
  }
}
</script>
<style>
  .supplier-edit-dialog {
    text-align: left;
  }
</style>
